import React, { Component } from 'react'
import './css/11-实例选项卡.css'
import Film from './maizuoComponent/Film'
import Cinema from './maizuoComponent/Cinema'
import Center from './maizuoComponent/Center'
import Tabbar from './maizuoComponent/Tabbar'
import Navbar from './maizuoComponent/Navbar'

// 非受控组件：每个子组件有自己的状态，父组件不能达到完全控制子组件的行为

export default class App extends Component {
    state={
        
        current:0
    }
    
      switchTab=()=>{
        switch(this.state.current){
            case 0:
                return <Film></Film>
            case 1:
                return <Cinema></Cinema>
            case 2:
                return <Center></Center>
            default:
                return null
        }
      }
  render() {
    return (
      <div>
        <Navbar onEvent={(index)=>{
            this.setState({
                current:index
            })
        }}/>
        {this.switchTab()}
       <Tabbar event={(index)=>{
        this.setState({
            current:index
        })
       }}></Tabbar>
      </div>
    )
  }

}
